
<template>
    <div>
        <el-select v-model="subjectList" @change="projectChange" placeholder="请选择科目" multiple style="width:100%;">
            <el-option v-for="it in trainKeMarr" :key="it.value" :label="it.label" :value="it.value">
            </el-option>
        </el-select>
           
    </div>
</template>

<script>
import axios from 'axios'
import httpUrl from '@/assets/common'
import {
    Message
} from 'element-ui';
export default {
    props: ['classArr'],
    data() {
        return { 
            trainKeMarr: [],
            subjectList: []
        }
    },
    watch: {
        classArr(val) {
            this.trainKeM(val)
        }
    },
    methods: {
        // 多选科目
        trainKeM(val) {
            this.trainKeMarr = []
            axios({
                method: 'post',
                url: httpUrl + 'web/Dictionary/getSubject',
                data:{ gradeList: val },
                headers: { 'token': this.TOKEN }
            }).then(res => {
                if (res.data.code == 200) {
                    let respon = res.data.data
                    for (let i = 0; i < respon.length; i++) {
                        this.trainKeMarr.push({ value: respon[i].id, label: respon[i].subject })
                    }
                }
            })
        },

        projectChange(val) {
            log(val)
            this.$emit('project-change', val)
        }
    },
     
}
</script>

 
 
